<template>
  <div class="mainCon">
    <topTitle
      :titleText="titleText"
      :titleExplain="titleExplain"
      class="topConStyle"
    ></topTitle>
    <div class="mainConHeader">
      <div class="mainConHeaderContent"></div>
      <el-tabs
        v-model="activeName"
        type="card"
        @tab-click="handleClick"
        class="commonTab"
      >
        <el-tab-pane
          :label="item.label"
          :name="item.id"
          v-for="item in list"
          :key="item.id"
        ></el-tab-pane>
      </el-tabs>
      <keep-alive>
        <component v-bind:is="currentTabComponent"></component>
      </keep-alive>
    </div>
  </div>
</template>

<script>
import employmentInfo from './employmentInfo'
import unemploymentInfo from './unemploymentInfo'
import common from '../../kits/common'

export default {
  name: 'employmentInfoTab',
  components: {
    employmentInfo,
    unemploymentInfo,
  },
  data() {
    return {
      titleText: '就业信息',
      titleExplain: '由梁子湖区就业局推送的数据',
      activeName: '1',
      list: [
        {
          id: '1',
          label: '就业信息',
        },
        {
          id: '2',
          label: '失业信息',
        },
      ],
      currentTabComponent: 'employmentInfo',
    }
  },
  created() {
    if (this.$route.query.tab) {
      this.currentTabComponent = this.$route.query.tab
      this.taskType = this.$route.query.taskType || this.taskType
      this.activeName = this.$route.query.tab == 'employmentInfo' ? '1' : '2'
    }
  },
  watch: {
    // $route(to, from) {
    //   if (this.$route.query.tab) {
    //       this.taskType = this.$route.query.taskType || this.taskType;
    //       this.currentTabComponent = this.$route.query.tab;
    //       this.activeName = this.$route.query.tab == "employmentInfo" ? "1" : "2";
    //   }
    // }
  },
  methods: {
    //tabs栏切换
    handleClick(tab, event) {
      if (this.activeName == 1) {
        this.currentTabComponent = employmentInfo
      } else if (this.activeName == 2) {
        this.currentTabComponent = unemploymentInfo
      }
    },
    downLoad() {
      window.location.href =
        common.commonApi +
        'api-su/cs/salary/expand/bankSalaryTemplateDown?access_token=' +
        localStorage.getItem('access_token')
    },
  },
}
</script>

<style scoped lang="less">
.mainCon {
  top: 132px;
  padding: 0;
  &Header {
    position: relative;
    &Content {
      position: absolute;
      left: 130px;
      z-index: 100;
      font-size: 12px;
      color: #666666;
    }
  }
  .topConStyle {
    margin: 0 !important;
  }
}
.returnData {
  position: absolute;
  right: 24px;
  top: 18px;
}
</style>
